<?php

namespace App\Resource\Admin;

use App\Model\SystemInformation;
use Hyperf\Resource\Json\JsonResource;

/**
 * @mixin SystemInformation
 */
class SystemInfoResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array
     */
    public function toArray(): array
    {
        return [
            'id' => $this->id,
            'cpu_usage_rate' => $this->cpu_usage_rate,
            'memory_usage' => $this->memory_usage,
            'memory_total' => $this->memory_total,
            'disk_usage' => $this->disk_usage,
            'disk_total' => $this->disk_total,
            'active_conn' => $this->active_conn,
            'mysql_conn' => $this->mysql_conn,
            'mysql_conn_total' => $this->mysql_conn_total,
            'redis_memory_usage' => $this->redis_memory_usage,
            'redis_memory_total' => $this->redis_memory_total,
            'mysql_qps' => $this->mysql_qps,
            'active_users' => $this->active_users,
            'app_rps' => $this->app_rps,
            'error_rate' => $this->error_rate,
            'created_at' => $this->created_at->format('Y-m-d H:i:s'),
        ];
    }
}
